package com.travelsky.flash.util.handler;

import org.tmatesoft.svn.core.SVNCancelException;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNEvent;
import org.tmatesoft.svn.core.wc.SVNEventAction;

import com.travelsky.flash.util.log.FlashLogger;

public class UpdateEventHandler implements ISVNEventHandler {
	
	private static FlashLogger logger = new FlashLogger(UpdateEventHandler.class);
	
	public void checkCancelled() throws SVNCancelException {
		// TODO Auto-generated method stub

	}

	public void handleEvent(SVNEvent event, double progress) throws SVNException {
		SVNEventAction action = event.getAction();
		SVNNodeKind nodeKind = event.getNodeKind();

		if (SVNNodeKind.DIR.equals(nodeKind)) {
			// folder
			System.out.println(event.getFile().getName());

		} else {
			// treat as file for all other type
			if (action == SVNEventAction.UPDATE_DELETE) {
				logger.info(event.getFile().getAbsolutePath());

			} else if (action == SVNEventAction.UPDATE_ADD
					|| action == SVNEventAction.UPDATE_UPDATE) {
				logger.info(event.getFile().getAbsolutePath());
			}
		}

	}

}
